<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Review Exam</title>
</head>
<body>

<c:set var="exam_response" value="${sessionScope.exam_response}"></c:set>
<c:if test="${empty exam_response}" >
	<c:redirect url="LoginServlet"></c:redirect>
</c:if>
<div id="header"><%@ include file="Header.jsp"%></div>
<div id="content">
<div id="alluser">

<div class="box">
	<div class="box-header well">
		<h2><i class=" icon-list-alt"></i> Review Exam ${exam_response.exam.examName}</h2>
	</div>
	<div class="box-content">
		<table class="table table-striped table-bordered bootstrap-datatable datatable">
			<thead><tr>
				<th>Question</th>
				<th>Choices</th>
				<th>Answer</th>
				<th>Change Answer</th>
			</tr></thead>
			<tbody>
			<c:forEach var="question" items="${exam_response.exam.questions}" varStatus="i">
			<tr>
				<td>${question.question}</td>
				<td>
				<c:forEach var="choice" items="${question.choices}">${choice.answer}<br/>
				</c:forEach>
				</td>
				<c:choose>
				<c:when test="${not empty exam_response.answers.get(question)}">
				<td>${exam_response.answers.get(question).answer}</td>
				<td><a class="btn btn-info" href="ReviewExamServlet?q_index=${i.index}&id=${question.questionId}&aid=${exam_response.answers.get(question).answerId}"><i class="icon-edit"></i> Edit</a></td>
				</c:when>
				<c:otherwise>
				<td></td>
				<td><a class="btn btn-info" href="ReviewExamServlet?q_index=${i.index}&id=${question.questionId}"><i class="icon-edit"></i> Edit</a></td>
				</c:otherwise>
				</c:choose>
			</tr>
			</c:forEach>
			</tbody>
		</table>
	</div>
	<form action="StudentResponseServlet" method="post">
	<center><input class="btn btn-success" type="submit" value="Submit Exam" /><br/></center>
		<input type="hidden" name="success" value="Exam submitted!">
	</form> 
</div>
</div>
<br/>
<br/>
</div>

</body>
</html>